Skip to content

A dart package which shows total and available space of disks in Linux and Windows

License

Notifications You must be signed in to change notification settings

gilnobrega/universal_disk_space

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Universal Disk Space

A Dart package which parses total and available disk spaces on Windows and UNIX-based systems (including Linux and macOS).

Usage

Add universal_disk_space as a dependency to your project's pubspec.yaml file.

Example

import 'dart:io';

import 'package:universal_disk_space/universal_disk_space.dart';

Future<void> main() async {
  // Initializes the DiskSpace class.
  final diskSpace = DiskSpace();

  // Scan for disks in the system.
  await diskSpace.scan();

  // A list of disks in the system.
  var disks = diskSpace.disks;

  // Prints the device path, mount path, and total size of each disk in system.
  for (final disk in disks) {
    print(disk.devicePath); // e.g.: 'C:\' in Windows or '/dev/sdc' in Linux
    print(disk
        .mountPath); // e.g.: 'C:\' or '\\nasdrive' in Windows or '/' in Linux
    print(disk.totalSize.toString()); // in bytes
    print(disk.usedSpace.toString()); // in bytes
    print(disk.availableSpace.toString()); // in bytes
    print('');
  }

  /// Searches for the disk that '/home' belongs to.
  /// Any FileSystemEntity can be used.
  var homeDisk = diskSpace.getDisk(Directory('/home'));
  print(homeDisk);
}

About

A dart package which shows total and available space of disks in Linux and Windows

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages